﻿using Dapper;
using Max.PH6_2006A.LowCode.DataAccess;
using Max.PH6_2006A.LowCode.Domain;
using Max.PH6_2006A.LowCode.IRespository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH6_2006A.LowCode.Respository
{
    public class SystemUserRespository : BaseRespository<SystemUser>, ISystemUserRespository
    {
        //DapperHelper _dapper;
        public SystemUserRespository(DapperHelper dapper) : base(dapper)
        {
            //_dapper = dapper;
        }

        //public async Task<int> UserConfigRoleAsync(List<SystemUserRole> userRoles)
        //{

        //    using (IDbConnection conn = _dapper.DbConnection)
        //    {
        //        conn.Open();
        //        int result = 0;
        //        //TranscationScope
        //        IDbTransaction transcation = conn.BeginTransaction();
        //        try
        //        {
        //            string sql = "delete from SystemUserRole where UserId=@UserId";
        //            int a = await conn.ExecuteAsync(sql, new { UserId = userRoles[0].UserId },transcation);

        //            sql = "insert into SystemUserRole(userid,roleid) values(@UserId,@RoleId)";
        //            a = await conn.ExecuteAsync(sql, userRoles,transcation);
        //            transcation.Commit();
        //        }
        //        catch (Exception)
        //        {
        //            transcation.Rollback();
        //            throw;
        //        }

        //        return result;
        //    }

        //}
    }
}
